package jiali.test.easyfactory_2;

public class CashContext {

    private CashSuper cashSuper;
    public CashContext(String type) {
        switch (type) {
            case "1":
                this.cashSuper = new CashNormal();
                break;
            case "2":
                this.cashSuper = new CashRebate(0.8d);
                break;
            case "3":
                this.cashSuper = new CashReturn(300d, 100d);
                break;
        }
    }

    public double getResult(double price, int num) {
        return this.cashSuper.acceptCash(price, num);
    }
}
